﻿var common = {
    is_app:function (_this) {
        try{
            if(localStorage.getItem("is_app") == true ||localStorage.getItem("is_app") == "true"){
                _this.base_url =this.get_base_url()
                // _this.$set(_this.data,"base_url",this.get_base_url());
                //this.base_url = this.
                return true
            }else{
                return false
            }
        }catch (e){
            console.log(e)
            return false
        }
    },
    //app 录音
    app_recoed: function (cb) {
        var r = plus.audio.getRecorder();
        r.record({ filename: "_doc/audio/" }, function (e) {
            console.log("recoed_seccess");
            //up_load(e);
            console.log(JSON.stringify(e));
            cb()
            return e
        }, function (e) {
            alert("Audio record failed: " + e.message);
        });
    },
    app_play_voice:function(url){
        mui.plusReady(function () {
            var p = plus.audio.createPlayer(url);
            p.play(function () {
                console.log("play_voice_sus");
            }, function (e) {
                console.log("voice fail");
            });
        })
    },
    //提交voice
    up_load: function(e,fail){
        var task = plus.uploader.createUpload("https:wx.yizhiweimeng.com/yizhiweimeng/api/user/file/upload",
            { method: "POST" }, function (t, status) {
                //上传完成
                if (status == 200) {
                    alert("Upload success: " + t.url);
                    return {
                        t: t,
                        s: status
                    }
                } else {
                    fail()
                }
            });
        task.addFile(e, { key: "file" });
        task.start();
    }
}



// (function () {
//     try{
//         var go_back =  document.getElementsByClassName("go_back")[0];
//         go_back.addEventListener("click",function () {
//             window.history.back();
//         })
//     }catch (e){
//         console.log(e)
//     }
// }());

    // document.getElementsByClassName("go_back")[0].addEventListener("click",function () {
    //         window.history.back();
    // })
